<template>
  <LoginOrRegister :is-register="false" @onSubmit="onSubmit" />
</template>

<script>
import { loginAPI } from '@/api/user'
import LoginOrRegister from '../components/LoginOrRegister.vue'
import { setToken } from '@/utils/storage'

export default {
  name: 'LoginPage',
  components: { LoginOrRegister },
  methods: {
    async onSubmit (values) {
      const res = await loginAPI(values)
      console.log('登录', res)
      setToken(res.data.token)
      this.$router.push('/')
    }
  }
}
</script>
